Add TarEntryFormat parameter to TarFile.CreateFromDirectory methods#123427
Add TarEntryFormat parameter to TarFile.CreateFromDirectory methods#123427iremyux wants to merge 5 commits intodotnet:mainfrom
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-formats-tar |
There was a problem hiding this comment.
Pull request overview
This PR adds new overloads to TarFile.CreateFromDirectory and TarFile.CreateFromDirectoryAsync methods that accept a TarEntryFormat parameter, allowing users to specify the tar archive format (V7, Ustar, Pax, or Gnu) when creating archives from directories. Previously, these methods always used the Pax format by default.
Changes:
- Added four new public API overloads with
TarEntryFormatparameter - Modified existing overloads to delegate to new overloads with
TarEntryFormat.Paxas default - Added
ValidateTarEntryFormathelper method to validate format parameter - Added comprehensive test coverage for the new overloads
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Formats.Tar/ref/System.Formats.Tar.cs | Added four new public API signatures for CreateFromDirectory and CreateFromDirectoryAsync with TarEntryFormat parameter |
| src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarFile.cs | Implemented new overloads, added format validation, updated internal methods to accept format parameter, modified existing methods to delegate with Pax default |
| src/libraries/System.Formats.Tar/tests/TarFile/TarFile.CreateFromDirectory.Stream.Tests.cs | Added tests for invalid format validation and format-specific archive creation |
| src/libraries/System.Formats.Tar/tests/TarFile/TarFile.CreateFromDirectory.File.Tests.cs | Added tests for invalid format validation and format-specific archive creation |
| src/libraries/System.Formats.Tar/tests/TarFile/TarFile.CreateFromDirectoryAsync.Stream.Tests.cs | Added async tests for invalid format validation and format-specific archive creation |
| src/libraries/System.Formats.Tar/tests/TarFile/TarFile.CreateFromDirectoryAsync.File.Tests.cs | Added async tests for invalid format validation and format-specific archive creation |
src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarFile.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarFile.cs
Outdated
Show resolved
Hide resolved
| throw new DirectoryNotFoundException(SR.Format(SR.IO_PathNotFound_Path, sourceDirectoryName)); | ||
| } | ||
|
|
||
| ValidateTarEntryFormat(format); |
There was a problem hiding this comment.
Is this validation necessary, or will it be handled implicitly by the underlying TarWriter?
There was a problem hiding this comment.
Yes, TarWriter already validates the format, I added so it fails early. But yes, it is redundant
|
Closing since it's a duplicate of #123407 |
This PR adds new overloads to
TarFile.CreateFromDirectoryandTarFile.CreateFromDirectoryAsyncthat accept aTarEntryFormatparameter, allowing users to specify the tar archive format when creating archives from directories. Currently,TarFile.CreateFromDirectoryalways creates archives usingTarEntryFormat.Pax.API Changes
Implements #121819